package com.carlinfo.hospital.dao;

import com.carlinfo.hospital.pojo.Person;
import com.carlinfo.hospital.util.DataSourceUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.junit.Test;

import javax.sql.DataSource;
import java.sql.SQLException;

public class testDao {
    @Test
    public void test02() {
        DataSource dataSource = DataSourceUtil.getInstance();
        QueryRunner queryRunner = new QueryRunner(dataSource);
        System.out.println(queryRunner);
        try {
            Person query = queryRunner.query("select * from person where id = 1", new BeanHandler<Person>(Person.class));
            System.out.println(query);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
